#ifndef __ARRAYCOMPAREGENERATOR__H__
#define __ARRAYCOMPAREGENERATOR__H__
#include "CompareGenerator.h"
#include<vector>
#include<random>

using namespace std;
class ArrayCompareGenerator:public CompareGenerator{
public:
    virtual bool GetCompareTemp(int length,int range) override;
    virtual void Print() override;
    bool IsEqual(vector<int>,vector<int>);

    vector<int> GetArray();
private:
    vector<int> array;
    
};

bool ArrayCompareGenerator::GetCompareTemp(int size,int range) 
{
    static default_random_engine e;
    static uniform_int_distribution<unsigned> u1(0,size);
    static uniform_int_distribution<signed> u2(-range,range);
    int len = u1(e);
    vector<int>().swap(array); 
    for(int i=0 ; i < len ; i++) {
        array.push_back(u2(e));
    }

    return true;
}

bool ArrayCompareGenerator::IsEqual(vector<int> arrayOne,vector<int> arrayTwo)
{
    if((arrayOne.size() == 0) && (arrayTwo.size() == 0)){
        return true;
    }
    if((arrayOne.size() != arrayTwo.size()) || (arrayOne.size() == 0) || (arrayTwo.size() == 0)) {
        return false;
    }
    
    for(int i = 0 ; i < arrayOne.size() ; i++) {
        if(arrayOne[i] != arrayTwo[i]) {
            return false;
        }
    }

    return true;
}

vector<int> ArrayCompareGenerator::GetArray() {
    return array;
}

void ArrayCompareGenerator::Print()
{
    for(auto i:array) {
        cout<<i<<" ";
    }
    cout<<endl;
}

#endif